import { createStore } from 'vuex'

export default createStore({
  state: {
    token: '',
    userInfo: {},
    // 购物车商品数量
    cartNum: 0
  },
  mutations: {
    savaToken(state, token) {
      state.token = token
      window.localStorage.setItem('token', token)
    },
    savaUserInfo(state, userInfo) {
      state.userInfo = userInfo
      window.localStorage.setItem('userInfo', JSON.stringify(userInfo))
    },
    savaCartNum(state, value) {
      state.cartNum = value
    }
  },
  actions: {
    // savaUser({commit}, payload) {
    //   console.log(payload);
    //   commit('savaUser',payload)
    // }
  },
  modules: {
  }
})
